import { useModel } from "umi";

import AddPositionModle from "../components/positions/Add";
import EditPositionModle from "../components/positions/Edit";

const useHelperPostion = () => {
    const { setModalVisible, setModalTitle, setModalWidth, setModalComponent } = useModel("global.modal");

    const openAddPositionModal = ({ reloadData }) => {
        setModalTitle("添加职位");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddPositionModle reloadData={reloadData} />);
    };

    const openEditPositionModal = ({ record, reloadData }) => {
        setModalTitle("编辑职位信息");
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<EditPositionModle item={record} reloadData={reloadData} />);
    };

    return { openAddPositionModal, openEditPositionModal };
};

export default useHelperPostion;
